home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-PR / Interfaces&Libraries / Multiprocessing StdCLib / CIncludes / stdlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-06  |  4.6 KB  |  211 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        stdlib.h
  3.  
  4.      Contains:    General utilities
  5.  
  6.      Version:    Technology:    StdCLib 3.4
  7.                  Release:    3.6d2
  8.  
  9.      Copyright:    © 1987-1996 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18.  
  19.  
  20. /*
  21.  * Get common declarations 
  22.  */
  23.  
  24. #ifndef __STDLIB__
  25. #define __STDLIB__
  26.  
  27. #ifndef __CONDITIONALMACROS__
  28. #include <ConditionalMacros.h>
  29. #endif
  30. #ifndef __NULLDEF__
  31. #include <NullDef.h>
  32. #endif
  33. #ifndef __SIZETDEF__
  34. #include <SizeTDef.h>
  35. #endif
  36. #ifndef __WCHARTDEF__
  37. #include <WCharTDef.h>
  38. #endif
  39.  
  40.  
  41. #if PRAGMA_ONCE_SUPPORTED
  42. #pragma once
  43. #endif  /* PRAGMA_ONCE_SUPPORTED */
  44.  
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48.  
  49. #if PRAGMA_IMPORT_SUPPORTED
  50. #pragma import on
  51. #endif
  52.  
  53. #if PRAGMA_ALIGN_SUPPORTED
  54. #pragma options align=mac68k
  55. #elif PRAGMA_PACK_SUPPORTED
  56. #pragma pack(push, 2)
  57. #endif
  58.  
  59.  
  60.  
  61. struct div_t {
  62.     int                             quot;                        /* quotient */
  63.     int                             rem;                        /* remainder */
  64. };
  65. typedef struct div_t div_t;
  66.  
  67. struct ldiv_t {
  68.     long                             quot;                        /* quotient */
  69.     long                             rem;                        /* remainder */
  70. };
  71. typedef struct ldiv_t ldiv_t;
  72.  
  73. #define EXIT_FAILURE 1
  74. #define EXIT_SUCCESS 0
  75. #define RAND_MAX 32767
  76. #define MB_CUR_MAX 1
  77.  
  78. /*
  79.  *    String conversion functions
  80.  */
  81.  
  82. extern double atof(const char *nptr);
  83. extern int atoi(const char *nptr);
  84. extern long atol(const char *nptr);
  85. extern double strtod(const char *nptr, char **endptr);
  86. extern long strtol(const char *nptr, char **endptr, int base);
  87. extern unsigned long strtoul(const char *nptr, char **endptr, int base);
  88.  
  89. /*
  90.  *    Pseudo-random sequence generation functions
  91.  */
  92.  
  93. extern int rand(void );
  94. extern void srand(unsigned int seed);
  95.  
  96. /*
  97.     re-entrant-safe "rand". The function "rand_r" is safe to 
  98.     use in re-entrant situations including preemptive
  99.     68k threads or preemptive tasks provided by the
  100.     Multiprocessing Library for PowerPC/System 7.
  101.     
  102.     To make the prototype for this function visible, 
  103.     you must #define _POSIX_THREAD_SAFE_FUNCTIONS 1
  104.     via command-line compiler-directive or equivalent
  105.     option.  This function is not available in versions
  106.     of StdCLib prior to 3.5a1.
  107. */
  108.  
  109. #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
  110. extern int rand_r(unsigned int *seed);
  111. #endif  /*  defined(_POSIX_THREAD_SAFE_FUNCTIONS)  */
  112.  
  113.  
  114. /*
  115.  *    Memory management functions
  116.  */
  117.  
  118. extern void *calloc(size_t nmemb, size_t size);
  119. extern void free(void *ptr);
  120. extern void *malloc(size_t size);
  121. extern void *realloc(void *ptr, size_t size);
  122.  
  123. /*
  124.  *    Communication with the environment
  125.  */
  126.  
  127. typedef void (*_Atexitfuncptr)(void );
  128. extern void abort(void );
  129. extern int atexit(_Atexitfuncptr func);
  130. extern void exit(int status);
  131. extern char *getenv(const char *name);
  132. extern int system(const char *str);
  133.  
  134. /*
  135.  *    Searching and sorting utilities
  136.  */
  137.  
  138. typedef int (*_Cmpfuncptr)(const void *p, const void *q);
  139. extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, _Cmpfuncptr cmpfunptr);
  140. extern void qsort(void *base, size_t nmemb, size_t size, _Cmpfuncptr cmpfunptr);
  141.  
  142. /*
  143.  *    Integer arithmetic functions
  144.  */
  145.  
  146. extern int abs(int j);
  147. extern div_t div( int numer , int denom );
  148. extern long labs(long j);
  149. extern ldiv_t ldiv(long numer, long denom);
  150.  
  151.  
  152. /*
  153.  *    Multibyte functions
  154.  */
  155.  
  156. extern int mblen(const char *s, size_t n);
  157. extern int mbtowc(wchar_t *pwc, const char *s, size_t n);
  158. extern int wctomb(char *s, wchar_t wchar);
  159. extern size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);
  160. extern size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);
  161.  
  162. /*
  163.  *  Apple extentions
  164.  */
  165.  
  166. #if defined(__useAppleExts__) || defined(applec) && !defined(__STDC__) || defined(__PPCC__) && !__STDC__
  167.  
  168. extern void _exit(int status);
  169. extern int setenv(const char *varName, const char *value);
  170. #define putenv(x, y) setenv((x), (y))
  171.  
  172. #endif  /*  defined(__useAppleExts__)  || (( defined(applec)  &&  ! defined(__STDC__) ) || ( defined(__PPCC__)  &&  !__STDC__)) */
  173.  
  174.  
  175. #if defined(_LONG_LONG)
  176. /* Is long long supported? */
  177.  
  178.     struct lldiv_t {
  179.         long long int quot;        /* quotient  */
  180.         long long int rem;        /* remainder */
  181.     };
  182.  
  183.     typedef struct lldiv_t lldiv_t;
  184.  
  185.     extern long long int llabs (long long int j);
  186.     extern lldiv_t lldiv (long long int numer, long long int denom);
  187.     extern long long int strtoll (const char *nptr, char **endptr, int base);
  188.     extern unsigned long long int strtoull (const char *nptr, char **endptr, int base);
  189.     extern long long int atoll (const char *nptr);
  190.  
  191. #endif  /*  defined(_LONG_LONG)  */
  192.  
  193.  
  194.  
  195. #if PRAGMA_ALIGN_SUPPORTED
  196. #pragma options align=reset
  197. #elif PRAGMA_PACK_SUPPORTED
  198. #pragma pack(pop)
  199. #endif
  200.  
  201. #if PRAGMA_IMPORT_SUPPORTED
  202. #pragma import off
  203. #endif
  204.  
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208.  
  209. #endif /* __STDLIB__ */
  210.  
  211.